// ! 全局变量
import variables from '@/assets/styles/variables.scss'
// ! 默认设置变量
import defaultSettings from '@/settings'

const {
  showSettings,
  showTagsView,
  showCopyright,
  showSidebarLogo,
  fixedHeader,
} = defaultSettings

/**
 * ! theme 项目默认主题色
 * ! showSetting 显示设置组件
 * ! showTagsView 显示 Tags 栏
 * ! showSidebarLogo 显示侧边 logo
 * ! fixedHeader header 栏固定
 */
const state = {
  theme: variables.theme,
  showSettings: showSettings,
  showCopyright,
  tagsView: showTagsView,
  fixedHeader: fixedHeader,
  sidebarLogo: showSidebarLogo,
}

const mutations = {
  // ! 修改系统设置
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  },
}

const actions = {
  // ! 修改系统设置
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
}

export default { state, mutations, actions }
